package me.dr0n3.skyTravel;

import java.io.Serializable;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

/**
 * @author dr0n3
 * @date 20.03.2012
 */
public class Port implements Serializable
{
    
    // <editor-fold defaultstate="collapsed" desc="Variablen">
    public Cube cube;
    public String pw;
    public String name;
    public Port linkedPort;
    // </editor-fold>
    
    public Port(String name, String pw, Cube cube)
    {
        this.name = name;
        this.cube = cube;
        this.pw = pw;
    }
    
    public boolean teleportToLinkedPort(Player player)
    {
        if(linkedPort != null)
        {
            player.teleport(linkedPort.cube.locAppear.getLocation());
            player.sendMessage(ChatColor.LIGHT_PURPLE + "Wir haben unser Ziel erreicht.");
            return true;
        }
        else
        {
            player.sendMessage(ChatColor.DARK_RED + "Das Schiff ist nicht fahrtüchtig.");
            return false;
        }
    }
    
    public boolean isInPort(Player player)
    {
        return cube.isInCube(player);
    }
    
    public boolean checkPassword(String s)
    {
        if(s.equals(pw))
            return true;
        else
            return false;
    }
}
